app.controller("bookInfoCtrl",function($scope,$state,$ionicLoading,$http,$ionicSlideBoxDelegate,$stateParams){
    var user_info = JSON.parse(localStorage.getItem("UserInfo"));
    var bookInfo = JSON.parse(localStorage.getItem("bookInfo"));
    // var getPath = JSON.parse(localStorage.getItem("getPath"));
    angular.element(document).ready(function(){

        $scope.bookName = user_info.bookName;
        $scope.getCard($stateParams.queryDate);
    });

    //获取书籍卡片
    $scope.getCard = function (queryDate) {
        //获取学习计划
        var url = getPath.url+getPath.name+"/app/getCycleCard";
        var param = {
            userId:user_info.userId,
            bookId:user_info.bookId,
            bookId:bookInfo.bookId,
        }
        if(!queryDate){
            param.queryDate = new Date().Format("yyyy-MM-dd");
        }else{
            param.queryDate = queryDate;
        }
        $http({
            url: url,
            method: "POST",
            headers:{'Content-Type':'application/x-www-form-urlencoded'},
            data: param
        }).success(function (data) {
                if (data.resultCode == 200) {
                    var res = data.resultBean;
                    //书籍简介
                    var book = res.bookInfoDTO;
                    $scope.author = book.authors;
                    $scope.remarks = book.remarks;
                } else {
                    $ionicLoading.show({
                        template: "获取阅读章节失败",
                        duration: 3000
                    });
                }
            })
            .error(function () {
                $ionicLoading.hide();
                $ionicLoading.show({
                    template: "获取阅读章节失败",
                    duration: 3000
                });
            });
    }
});